﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

using Shove.Web.UI;

public partial class UserControls_HotSales : UCBase
{
    public UserControls_HotSales()
    {
        Name = "热销排行";

        swpas = new ShoveWebPartAttribute[5];

        swpas[0] = new ShoveWebPartAttribute_Int("行数", "1,100", 7, "显示销售排行的条数");        
        swpas[1] = new ShoveWebPartAttribute_Int("控件宽度", "", 203, "控件宽度");
        swpas[2] = new ShoveWebPartAttribute_Int("控件高度", "", 420, "控件高度");

        swpas[3] = new ShoveWebPartAttribute_Image("产品图片宽度", "1,500", 91, "产品图片宽度");
        swpas[4] = new ShoveWebPartAttribute_Image("产品图片高度", "1,500", 27, "产品图片高度");

    }

    private void InitlayOut()
    {
        tabctr.Width = swpAttributes[1];
        tabctr.Height = swpAttributes[2];
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        InitlayOut();
        BindData();
    }

    protected void dlNew_ItemDataBound(object sender, DataListItemEventArgs e)
    {
        //Image img = (Image)e.Item.FindControl("imgArrow");
        //HyperLink hlNews = (HyperLink)e.Item.FindControl("hlNews");
        //TextBox tbID = (TextBox)e.Item.FindControl("tbID");

        //img.ImageUrl = "~/images/UserControls/icon_" + (e.Item.ItemIndex + 1) + ".gif";
        //hlNews.Text = Shove._String.Cut(hlNews.Text, Shove._Convert.StrToInt(this.swpAttributes[1], 8));
        //hlNews.NavigateUrl = "~/Default.aspx?PN=goods_details&ID=" + tbID.Text;

        //HtmlTableCell tdtitle = (HtmlTableCell)e.Item.FindControl("tdtitle");
        //tdtitle.Height = swpAttributes[4];
        //tdtitle.Attributes.Add("class",swpAttributes[10]);

        //HtmlTableCell tdimg = (HtmlTableCell)e.Item.FindControl("tdimg");
        //tdimg.Height = swpAttributes[4];
        //tdimg.Attributes.Add("class", swpAttributes[11]);
    }

    private void BindData()
    {
        DataTable dt = null;
        int Count = Shove._Convert.StrToInt(swpAttributes[0], 5);

        try
        {
            dt = new DAL.Views.V_Shop_TopSales().Open("top " + Count + " *", "", "");

            rpSalesPro.DataSource = dt;
            rpSalesPro.DataBind();  
        }
        catch { }
    }
}
